#include "SwitchTriggerObject.h"

#include "..\Sprite Management\AnimationManager.h"

#include "..\Message Management\MessageID.h"
#include "..\Message Management\DeleteObjectMessage.h"

#include "..\..\SGD Wrappers\SGD_Geometry.h"
#include "..\..\SGD Wrappers\SGD_GraphicsManager.h"

SwitchTriggerObject::SwitchTriggerObject(unsigned int targetID = 0) : Message(MessageID::MSG_DELETE_OBJECT)
{
	iTargetID = targetID;
	SetTrigger(false);
}


SwitchTriggerObject::~SwitchTriggerObject()
{
}

int SwitchTriggerObject::Update(float dt)
{
	return 0;
}

void SwitchTriggerObject::Render()
{
	GameObject::Render();
}


void SwitchTriggerObject::HandleCollision(const GameObject* collision)
{
	if (!GetTrigger())
	{
		GAME->PlaySwitchAudio();
		// Send Delete Object Message
		DeleteObjectMessage* pMsg = new DeleteObjectMessage(this);
		pMsg->QueueMessage();
		pMsg = nullptr;

		// Set Trigger to true
		SetTrigger(true);
		
		// Change to button pushed image
		if (GetCurrentAnimationName() != "SwitchTriggerDown")
			SetAnimation("SwitchTriggerDown");
	}	
}

unsigned int SwitchTriggerObject::GetTargetID()
{
	return iTargetID;
}